package com.whmskj.xjlhbc.controller;

import cn.dev33.satoken.annotation.SaIgnore;
import com.whmskj.xjlhbc.core.AjaxResult;
import com.whmskj.xjlhbc.core.Page;
import com.whmskj.xjlhbc.domain.*;
import com.whmskj.xjlhbc.dto.QueryDto;
import com.whmskj.xjlhbc.service.IMachineInfoService;
import com.whmskj.xjlhbc.vo.JtKbVo;
import com.whmskj.xjlhbc.vo.RealInfo1Vo;
import com.whmskj.xjlhbc.vo.RealInfoVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.*;

@SaIgnore
@RestController
@RequestMapping("/jt/dashboard")
public class JtController {

    @Autowired
    private IMachineInfoService service;

    @GetMapping("/list")
    public AjaxResult list(QueryDto param){
        List<MachineInfo> list = service.queryList(param);
        return AjaxResult.success(list);
    }

    @GetMapping("/getZl")
    public AjaxResult getZl(String macid,@RequestParam(required = false,defaultValue = "0")int type){
        List list = service.getZl(macid,type);
        return AjaxResult.success(list);
    }

    @GetMapping("/realInfo")
    public AjaxResult realInfo(String macid){
        RealInfoVo result = service.realInfo(macid);
        return AjaxResult.success(result);
    }

    @GetMapping("/spareParts")
    public AjaxResult spareParts(String macid){
        List<BalanceSheetForSparePartsSbbj01> result = service.spareParts(macid);
        return Page.getDataTable(result);
    }

    @GetMapping("/wb")
    public AjaxResult wb(String macid){
        List<By01MaintenanceSchedule> result = service.wb(macid);
        return Page.getDataTable(result);
    }

    @GetMapping("/gz")
    public AjaxResult gz(String macid){
        List<SchedulingOfSbbx01MalfunctionRep> result = service.gz(macid);
        return Page.getDataTable(result);
    }

    @GetMapping("/bytc")
    public AjaxResult bytc(String macid){
        List<RealInfoVo.StopInfo> result = service.bytc(macid);
        return Page.getDataTable(result);
    }

    @GetMapping("/lstc")
    public AjaxResult lstc(String macid,@RequestParam(required = false) String dateymd){
        List<StopdataInfoHistory> result = service.lstc(macid,dateymd);
        return Page.getDataTable(result);
    }

    //准整车间
    @GetMapping("/zzList")
    public AjaxResult zzList(){
        List<Map<String, Object>> result = new ArrayList<>();
        Map<String, Object> map = new HashMap<>();
        map.put("type", 1);//整经机
        map.put("jtList", Arrays.asList("01", "02", "03", "04", "05", "06"));
        result.add(map);
        map = new HashMap<>();
        map.put("type", 2);//浆纱机
        map.put("jtList", Arrays.asList("01", "02"));
        result.add(map);
        map = new HashMap<>();
        map.put("type", 3);//锅炉
        map.put("jtList", Arrays.asList("01", "02"));
        result.add(map);
        map = new HashMap<>();
        map.put("type", 4);//经轴库
        map.put("jtList", Arrays.asList("01", "02"));
        result.add(map);
        return AjaxResult.success(result);
    }

    //准整车间实时信息
    @GetMapping("/realInfo1")
    public AjaxResult realInfo1(String macid,@RequestParam(required = false,defaultValue = "1")int type){
        RealInfo1Vo result= service.realInfo1(macid,type);
        return AjaxResult.success(result);
    }

    //看板
    @GetMapping("kb")
    public AjaxResult kb(){
        JtKbVo result = service.jtKb();
        return AjaxResult.success(result);
    }
    //经轴库看板
    @GetMapping("jzkkb")
    public AjaxResult jzkkb(){
        JtKbVo result = service.jzkkb();
        return AjaxResult.success(result);
    }

    //整经/浆纱机看板
    @GetMapping("jszjkb")
    public AjaxResult jszjkb(){
        JtKbVo result = service.jszjkb();
        return AjaxResult.success(result);
    }

}
